package w3_c2_queue;
import java.util.Stack;

public class LC_232 {
    public static void main(String[] args) {
        MyQueue stack = new MyQueue();
        stack.push(1);
        stack.push(2);
        System.out.println(stack.peek());
        System.out.println(stack.pop());
        System.out.println(stack.empty());
    }
}
class MyQueue {
    private Stack<Integer> a;
    private Stack<Integer> b;
    int front;
    public MyQueue() {
        a = new Stack<>();
        b = new Stack<>();
    }

    public void push(int x) {
        if(a.isEmpty())
            front = x;
        a.push(x);
    }

    public int pop() {
        if(b.isEmpty())
            while(!a.isEmpty())
                b.push(a.pop());
       return b.pop();
    }

    public int peek() {
        if(!b.isEmpty())
            return b.peek();
        return front;
    }

    public boolean empty() {

        return b.isEmpty() && a.isEmpty();
    }
}

